export default {
  computed: {
    field() {
      return this.designer.fieldLib[this.selectedId]
    },
    selectedId() {
      return this.designer.selectedId
    },
    selectedWidget() {
      return this.designer.fieldLib[this.selectedId]
    }
  },
  methods: {
    hasConfig(configName) {
      return this.designer.hasConfig({}, configName)
    },

    inputNumberHandler({ target }) {
      target.value = target.value.replace(/[^0-9]/gi, '')
    },

    onRemoteChange(val) {
      if (val) {
        this.optionModel.filterable = true
        this.optionModel.allowCreate = false
      }
    },

    onMultipleSelected(val) {
      if (val) {
        // debugger

        // 清空已选项，否则console会报错！！
        // let foundRef = this.designer.formWidget.getWidgetRef(this.optionModel.name)
        // if (!!foundRef && !!foundRef.clearSelectedOptions) {
        //   foundRef.clearSelectedOptions()
        // }

        this.optionModel.defaultValue = []
      } else {
        if (!!this.optionModel.defaultValue && (this.optionModel.defaultValue.length > 0)) {
          this.optionModel.defaultValue = this.optionModel.defaultValue[0]
        } else {
          this.optionModel.defaultValue = ''
        }
      }
    },

  }
}
